{"ast":null,"code":"import _slicedToArray from \"/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@babel/runtime/helpers/esm/slicedToArray.js\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport * as React from 'react';\nimport { ConfigContext } from '../../config-provider';\nimport LocaleReceiver from '../../locale/LocaleReceiver';\nimport defaultLocale from '../../locale/en_US';\nimport ConfirmDialog from '../ConfirmDialog';\nvar HookModal = function HookModal(_ref, ref) {\n  var afterClose = _ref.afterClose,\n    config = _ref.config;\n  var _a;\n  var _React$useState = React.useState(true),\n    _React$useState2 = _slicedToArray(_React$useState, 2),\n    open = _React$useState2[0],\n    setOpen = _React$useState2[1];\n  var _React$useState3 = React.useState(config),\n    _React$useState4 = _slicedToArray(_React$useState3, 2),\n    innerConfig = _React$useState4[0],\n    setInnerConfig = _React$useState4[1];\n  var _React$useContext = React.useContext(ConfigContext),\n    direction = _React$useContext.direction,\n    getPrefixCls = _React$useContext.getPrefixCls;\n  var prefixCls = getPrefixCls('modal');\n  var rootPrefixCls = getPrefixCls();\n  var close = function close() {\n    setOpen(false);\n    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n      args[_key] = arguments[_key];\n    }\n    var triggerCancel = args.some(function (param) {\n      return param && param.triggerCancel;\n    });\n    if (innerConfig.onCancel && triggerCancel) {\n      innerConfig.onCancel.apply(innerConfig, [function () {}].concat(_toConsumableArray(args.slice(1))));\n    }\n  };\n  React.useImperativeHandle(ref, function () {\n    return {\n      destroy: close,\n      update: function update(newConfig) {\n        setInnerConfig(function (originConfig) {\n          return Object.assign(Object.assign({}, originConfig), newConfig);\n        });\n      }\n    };\n  });\n  var mergedOkCancel = (_a = innerConfig.okCancel) !== null && _a !== void 0 ? _a : innerConfig.type === 'confirm';\n  return /*#__PURE__*/React.createElement(LocaleReceiver, {\n    componentName: \"Modal\",\n    defaultLocale: defaultLocale.Modal\n  }, function (contextLocale) {\n    return /*#__PURE__*/React.createElement(ConfirmDialog, Object.assign({\n      prefixCls: prefixCls,\n      rootPrefixCls: rootPrefixCls\n    }, innerConfig, {\n      close: close,\n      open: open,\n      afterClose: afterClose,\n      okText: innerConfig.okText || (mergedOkCancel ? contextLocale.okText : contextLocale.justOkText),\n      direction: direction,\n      cancelText: innerConfig.cancelText || contextLocale.cancelText\n    }));\n  });\n};\nexport default /*#__PURE__*/React.forwardRef(HookModal);","map":{"version":3,"names":["_toConsumableArray","React","ConfigContext","LocaleReceiver","defaultLocale","ConfirmDialog","HookModal","_ref","ref","afterClose","config","_a","useState","open","setOpen","innerConfig","setInnerConfig","useContext","direction","getPrefixCls","prefixCls","rootPrefixCls","close","_len","arguments","length","args","Array","_key","triggerCancel","some","param","onCancel","apply","concat","slice","useImperativeHandle","destroy","update","newConfig","originConfig","Object","assign","mergedOkCancel","okCancel","type","createElement","componentName","Modal","contextLocale","okText","justOkText","cancelText","forwardRef"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/antd/es/modal/useModal/HookModal.js"],"sourcesContent":["import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport * as React from 'react';\nimport { ConfigContext } from '../../config-provider';\nimport LocaleReceiver from '../../locale/LocaleReceiver';\nimport defaultLocale from '../../locale/en_US';\nimport ConfirmDialog from '../ConfirmDialog';\nconst HookModal = (_ref, ref) => {\n  let {\n    afterClose,\n    config\n  } = _ref;\n  var _a;\n  const [open, setOpen] = React.useState(true);\n  const [innerConfig, setInnerConfig] = React.useState(config);\n  const {\n    direction,\n    getPrefixCls\n  } = React.useContext(ConfigContext);\n  const prefixCls = getPrefixCls('modal');\n  const rootPrefixCls = getPrefixCls();\n  const close = function () {\n    setOpen(false);\n    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n      args[_key] = arguments[_key];\n    }\n    const triggerCancel = args.some(param => param && param.triggerCancel);\n    if (innerConfig.onCancel && triggerCancel) {\n      innerConfig.onCancel.apply(innerConfig, [() => {}].concat(_toConsumableArray(args.slice(1))));\n    }\n  };\n  React.useImperativeHandle(ref, () => ({\n    destroy: close,\n    update: newConfig => {\n      setInnerConfig(originConfig => Object.assign(Object.assign({}, originConfig), newConfig));\n    }\n  }));\n  const mergedOkCancel = (_a = innerConfig.okCancel) !== null && _a !== void 0 ? _a : innerConfig.type === 'confirm';\n  return /*#__PURE__*/React.createElement(LocaleReceiver, {\n    componentName: \"Modal\",\n    defaultLocale: defaultLocale.Modal\n  }, contextLocale => /*#__PURE__*/React.createElement(ConfirmDialog, Object.assign({\n    prefixCls: prefixCls,\n    rootPrefixCls: rootPrefixCls\n  }, innerConfig, {\n    close: close,\n    open: open,\n    afterClose: afterClose,\n    okText: innerConfig.okText || (mergedOkCancel ? contextLocale.okText : contextLocale.justOkText),\n    direction: direction,\n    cancelText: innerConfig.cancelText || contextLocale.cancelText\n  })));\n};\nexport default /*#__PURE__*/React.forwardRef(HookModal);"],"mappings":";AAAA,OAAOA,kBAAkB,MAAM,8CAA8C;AAC7E,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,aAAa,QAAQ,uBAAuB;AACrD,OAAOC,cAAc,MAAM,6BAA6B;AACxD,OAAOC,aAAa,MAAM,oBAAoB;AAC9C,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,IAAMC,SAAS,GAAG,SAAZA,SAAS,CAAIC,IAAI,EAAEC,GAAG,EAAK;EAC/B,IACEC,UAAU,GAERF,IAAI,CAFNE,UAAU;IACVC,MAAM,GACJH,IAAI,CADNG,MAAM;EAER,IAAIC,EAAE;EACN,sBAAwBV,KAAK,CAACW,QAAQ,CAAC,IAAI,CAAC;IAAA;IAArCC,IAAI;IAAEC,OAAO;EACpB,uBAAsCb,KAAK,CAACW,QAAQ,CAACF,MAAM,CAAC;IAAA;IAArDK,WAAW;IAAEC,cAAc;EAClC,wBAGIf,KAAK,CAACgB,UAAU,CAACf,aAAa,CAAC;IAFjCgB,SAAS,qBAATA,SAAS;IACTC,YAAY,qBAAZA,YAA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